package atguigu05._super.exer3;

/**
 * ClassName: CheckAccount
 * Package: atguigu05._super.exer3
 * Description:
 *
 * @Author BuTang
 * @Create 2023/3/6 22:15
 * @Version 1.0
 */
public class CheckAccount extends Account {

    public CheckAccount(int id, double balance, double annualInterestRate,double overdraft){
         super(id ,balance,annualInterestRate);
           this.overdraft=overdraft;
    }
    private Double overdraft;
    public void withdraw(double amount){

        if (amount <=  getBalance()) {
            setBalance(getBalance() - amount);
            System.out.println("取款成功："+amount +"\t "+" 你的余额为："+ getBalance());
        }else if (amount >= (getBalance()+overdraft)) {
            System.out.println("超过可透支的金额");
        }else if (amount >=getBalance() && amount <= (getBalance()+overdraft)){

            overdraft = amount -getBalance();
            setBalance(0);
            System.out.println("取款成功："+amount +"\t "+" 你的余额为："+ getBalance()+"\t你透支的金额为："+overdraft);
        }
    }

}
